using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_LevelBuffToggle : UIBaseNode
    {
        #region Template Generate,don't modify
        protected class UIB_UIN_LevelBuffToggle
        {
            #region ObjectBinding Generate 
            public ExImage icon { protected set; get; }
            public ExText stack { protected set; get; }
            public ExText time { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<ExImage>("icon", out var __tbv0);
                icon = __tbv0;
                __binding.TryGetVariableValue<ExText>("stack", out var __tbv1);
                stack = __tbv1;
                __binding.TryGetVariableValue<ExText>("time", out var __tbv2);
                time = __tbv2;
            }


            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify


        protected UIB_UIN_LevelBuffToggle ui { get; set; }

        private ExImage _buffIcon;
        private ExText _stack;
        private ExText _time;

        #region Override
        protected override void BeforeInit()
        {
            ui = new UIB_UIN_LevelBuffToggle();
            ui.InitBinding(csObjBind);
        }

        protected override void OnInit()
        {
            _buffIcon = ui.icon;
            _stack = ui.stack;
            _time = ui.time;
            _time.text = string.Empty;
        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        public void ShowByData(LevelBuffData levelBuffData)
        {
            if (levelBuffData == null)
            {
                return;
            }
            Show();
            if (!string.IsNullOrEmpty(levelBuffData.cfgBuff.Icon))
            {
                SetImageSprite(_buffIcon, levelBuffData.cfgBuff.Icon_fullPath);
            }
            _stack.text = levelBuffData.stack > 1 ? levelBuffData.stack.ToString() : string.Empty;
        }

        protected override void OnDispose()
        {

        }
        #endregion
    }
}
